package mr.zhang.controller;

import mr.zhang.service.MerChantPropertyService;
import mr.zhang.util.PageModelMerChantProperty;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;



public class QuertyMnerchantPropertyController extends AbstractController {

	private MerChantPropertyService merChantPropertyService;

	private String toview;

	public MerChantPropertyService getMerChantPropertyService() {
		return merChantPropertyService;
	}

	public void setMerChantPropertyService(
			MerChantPropertyService merChantPropertyService) {
		this.merChantPropertyService = merChantPropertyService;
	}

	public String getToview() {
		return toview;
	}

	public void setToview(String toview) {
		this.toview = toview;
	}

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub

		int offset = 0;

		int pagesize = 3;

		try {

			offset = Integer.parseInt(request.getParameter("pager.offset"));

		} catch (Exception e) {
			// TODO: handle exception

			System.out.println("类型转化失败");
		}
		
		PageModelMerChantProperty pageModelMerChantProperty = this.merChantPropertyService.queryMerchantProperty(offset, pagesize);
		
		Map<String,Object> model = new HashMap<String,Object>();
		
		model.put("pageModelMerChantProperty", pageModelMerChantProperty);

		return new ModelAndView(getToview(),model);
	}

}
